package uk.co.BexhillWeb.MediaManager.Windows;

import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;

import javax.swing.JPanel;

@SuppressWarnings("serial")
public class ButtonPanel extends JPanel {

	public ButtonPanel(ArrayList<Component> components) {
		setLayout(new GridBagLayout());
		
        for (int i = 0; i < components.size(); i++) {
            GridBagConstraints gbc = makeGbc(0, i);
            //JPanel panel = new JPanel();
            //	panel.add(components.get(i));
            //gbc = makeGbc(1, i);
            add(components.get(i), gbc);
        }
	}
	
	private GridBagConstraints makeGbc(int x, int y) {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridwidth = 1;
        gbc.gridheight = 1;
        gbc.gridx = x;
        gbc.gridy = y;
        gbc.weightx = x;
        gbc.weighty = 1.0;
        gbc.insets = new Insets(5, 5, 5, 5);
        gbc.anchor = (x == 0) ? GridBagConstraints.LINE_START : GridBagConstraints.LINE_END;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        return gbc;
    }
}
